home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2 - Developers' Solutions / Delphi 2 Developers' Solutions.iso / dds / chap07 / howto03 / tabprops / propform.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-09-10  |  5.8 KB  |  191 lines

  1. unit Propform;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, DB, DBTables;
  8.  
  9. type
  10.   TTablePropertyForm = class(TForm)
  11.     SelectedTable: TTable;
  12.     DatabaseListBox: TListBox;
  13.     TableListBox: TListBox;
  14.     PropertyListBox: TListBox;
  15.     SaveToFileButton: TButton;
  16.     SaveToFileDialog: TSaveDialog;
  17.     procedure FormCreate(Sender: TObject);
  18.     procedure DatabaseListBoxClick(Sender: TObject);
  19.     procedure TableListBoxClick(Sender: TObject);
  20.     procedure SaveToFileButtonClick(Sender: TObject);
  21.   private
  22.     { Private declarations }
  23.   public
  24.     { Public declarations }
  25.   end;
  26.  
  27. var
  28.   TablePropertyForm: TTablePropertyForm;
  29.  
  30. implementation
  31.  
  32. {$R *.DFM}
  33.  
  34. uses DBiTypes, DbiProcs;
  35.  
  36. procedure TTablePropertyForm.FormCreate(Sender: TObject);
  37. begin
  38.   Session.GetDatabaseNames(DatabaseListbox.Items);
  39. end;
  40.  
  41. procedure TTablePropertyForm.DatabaseListBoxClick(Sender: TObject);
  42. begin
  43.   TableListBox.Clear;
  44.   PropertyListBox.Clear;
  45.   Session.GetTableNames(
  46.     DatabaseListBox.Items[DatabaseListbox.ItemIndex],
  47.     '',
  48.     True,
  49.     False,
  50.     TableListBox.Items
  51.   );
  52. end;
  53.  
  54. procedure TTablePropertyForm.TableListBoxClick(Sender: TObject);
  55. var
  56.   SelectedTableProperty: CURProps;
  57.   TheDatabaseName: DBINAME;
  58.   TheDatabaseNameLength: Word;
  59. begin
  60.   with SelectedTable do
  61.   begin
  62.     Close;
  63.     DatabaseName := DatabaseListbox.Items[
  64.       DatabaseListbox.ItemIndex
  65.     ];
  66.     TableName := TableListbox.Items[TableListbox.ItemIndex];
  67.     Open;
  68.     Check(
  69.       DbiGetProp(
  70.         hDBIObj( Handle) ,
  71.         dbDATABASENAME,
  72.         @(TheDatabaseName),
  73.         sizeOf( TheDatabaseName ),
  74.         TheDatabaseNameLength
  75.       )
  76.     );
  77.     Check( DbiGetCursorProps( Handle, SelectedTableProperty ));
  78.   end;
  79.   with PropertyListBox.Items, SelectedTableProperty do
  80.   begin
  81.     Clear;
  82.     Add( 'Database Name: ' + StrPas( TheDatabaseName));
  83.     { table name (no extension, if it can be derived) }
  84.     Add( 'Table Name: ' + StrPas( szName ));
  85.     { Full file name size }
  86.     Add( 'File Name Size: ' + IntToStr( iFNameSize ));
  87.     { Driver type }
  88.     Add( 'Table Type: ' + StrPas( szTableType ));
  89.     { No of fields in Table }
  90.     Add( 'Number of Fields: ' + IntToStr( iFields ));
  91.     { Record size (logical record) }
  92.     Add( 'Logical Record Size: ' + IntToStr( iRecSize ));
  93.     { Record size (physical record) }
  94.     Add( 'Physical Record Size: ' + IntToStr( iRecBufSize ));
  95.     { Key size }
  96.     Add( 'Key Size: ' + IntToStr( iKeySize ));
  97.     { Number of indexes }
  98.     Add( 'Number of Indexes: ' + IntToStr( iIndexes ));
  99.     { Number of val checks }
  100.     Add( 'Number of Validity Checks: ' + IntToStr( iValChecks ));
  101.     { Number of Referential Integrity constraints }
  102.     Add( 'Number of RIs: ' + IntToStr( iRefIntChecks ));
  103.     { Bookmark size }
  104.     Add( 'Bookmark Size: ' + IntToStr( iBookMarkSize ));
  105.     { Stable book marks }
  106.     Add( 'Stable Book Marks: ' +
  107.       IntToStr( Integer( bBookMarkStable) ));
  108.     { ReadOnly / RW }
  109.     Add( 'Read Only: ' + IntToStr( Integer( eOpenMode )));
  110.     { Excl / Share }
  111.     Add( 'Share Mode: ' + IntToStr( Integer( eShareMode )));
  112.     { Index is in use }
  113.     Add( 'Index in Use: ' + IntToStr( Integer( bIndexed )));
  114.     { 1: Has Seqnums; 0: Has Record# }
  115.     Add( 'Seq/Rec Num: ' + IntToStr( iSeqNums ));
  116.     { Supports soft deletes }
  117.     Add( 'Soft Deletes: ' + IntToStr( Integer( bSoftDeletes )));
  118.     { If above, deleted recs seen }
  119.     Add( 'Deleted On: ' + IntToStr( Integer( bDeletedOn )));
  120.     { Translate Mode }
  121.     Add( 'Translate Mode: ' + IntToStr( Integer( exltMode )));
  122.     { Restructure version number }
  123.     Add( 'Restructure Version: ' + IntToStr( iRestrVersion ));
  124.     { Cursor is uni-directional }
  125.     Add( 'Unidirectional: ' +
  126.       IntToStr( Integer( bUniDirectional )));
  127.     { Table  rights }
  128.     Add( 'Table Rights: ' + IntToStr( Integer( eprvRights )));
  129.     { Family rights      }
  130.     Add( 'Family Rights: ' + IntToStr( iFmlRights ));
  131.     { Number of Aux passwords }
  132.     Add( 'Auxliliary Passwords: ' + IntToStr( iPasswords ));
  133.     { Codepage (0 if unknown) }
  134.     Add( 'Codepage: ' + IntToStr( iCodePage ));
  135.     { Table is protected by password }
  136.     Add( 'Protected: ' + IntToStr( Integer( bProtected )));
  137.     { Driver dependent table level }
  138.     Add( 'Driver Table Level: ' + IntToStr( iTblLevel ));
  139.     { Language driver name }
  140.     Add( 'Language Driver: ' + StrPas( szLangDriver ));
  141.     { Field map active }
  142.     Add( 'Field Map On: ' + IntToStr( Integer( bFieldMap )));
  143.     { Physical file blocksize in K }
  144.     Add( 'Block Size (K): ' + IntToStr( iBlockSize ));
  145.     { Strict referential integrity }
  146.     Add( 'Strict RI: ' + IntToStr( Integer( bStrictRefInt )));
  147.     { Number of filters }
  148.     Add( 'Number of Filters: ' + IntToStr( iFilters ));
  149.     { Table is a temporary table }
  150.     Add( 'Temporary: ' + IntToStr( Integer( bTempTable )));
  151.   end;
  152. end;
  153.  
  154. procedure TTablePropertyForm.SaveToFileButtonClick(Sender: TObject);
  155. var
  156.   TheFileName: String;
  157. begin
  158.   if PropertyListBox.Items.Count = 0 then
  159.   begin
  160.     messageBeep( $FFFF );
  161.     ShowMessage( 'No properties to save.');
  162.     exit
  163.   end;
  164.   if SelectedTable.Database.IsSqlBased then
  165.   begin
  166.     TheFileName := Copy( SelectedTable.TableName, 1, 8 );
  167.   end
  168.   else { Table is local }
  169.   begin
  170.     if Pos( '.', SelectedTable.TableName) > 0 then
  171.     begin
  172.       TheFileName := Copy(
  173.         SelectedTable.TableName,
  174.         1,
  175.         Pos( '.', SelectedTable.TableName) - 1
  176.       );
  177.     end
  178.     else
  179.     begin
  180.       TheFileName := SelectedTable.TableName;
  181.     end;
  182.   end;
  183.   SaveToFileDialog.FileName := TheFileName;
  184.   if SaveToFileDialog.Execute then
  185.   begin
  186.     PropertyListBox.Items.SaveToFile(SaveToFileDialog.FileName);
  187.   end;
  188. end;
  189.  
  190. end.
  191.